package components
{
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class clt_component extends uif_ecomponent {
		public function clt_component(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass: Object='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			createComponents();
		}
		
		protected function createComponents(): void {
			
		}
		
		public function get workspace(): clt_workspace {
			return (app as Object).workspace;
		}
		
		public function get clt(): clt_clothingBase {
			return app as clt_clothingBase;
		}		
		
		protected function addButton(caption: String, proc: Function, inner: Object, ctyleClass: Object='buttonB'): clt_arrowB {
			var result: clt_arrowB = new clt_arrowB(this, inner.x, inner.y, inner.width, inner.height, caption, proc, ctyleClass);
			inner.y += result.height;
			return result;
		}
		
		protected function addButtonSubmenu(caption: String, inner: Object, list: Array, onSelect: Function, onClick: Function=null, a_styleClass: Object='buttonB'): clt_plButton {
			var result: clt_plButton = new clt_plButton(this, inner.x, inner.y, inner.width, inner.height, caption, function(e: Event): void {
				if (onClick != null) onClick(e)
				else _menu.showMenu();
			}, a_styleClass);
			inner.y += result.height;
			
			var _menu: clt_popupMenu = new clt_popupMenu(clt.popupMenuLayer, result.title, list, onSelect);
			
			result.arrow.addEvent(MouseEvent.CLICK, function(e: Event): void {
				_menu.showMenu();
			});
			return result;
		}
		
		public function slideCenterToggle(setVisible: Boolean): void {
			if (setVisible) {
				(fx(uif_component.FIELD_SCALECENTER, scale, 1)).start();
				slideShow();
			} else {
				(fx(uif_component.FIELD_SCALECENTER, scale, 0.5)).start();
				slideHide();
			}
		}
	}
}